<?php

namespace App\Models\Factory;


use App\Constants\InviteConstant;
use App\Models\AbsModelFactory;
use SimpleSoftwareIO\QrCode\Facades\QrCode;

/**
 * 二维码
 */
class QrCodeFactory extends AbsModelFactory
{

    //生成二维码
    public static  function  getQrCode($code)
    {
        //获取邀请链接
        $inviteUrl = InviteConstant::INVITE_URL;


        $inviteUrl = $inviteUrl.'?'.'inviteCode='.$code;
         //生成二维码
        $qrCode = QrCode::format('png')->size('200')->merge('/public/qrcodes/qrcode.png',.15)->generate($inviteUrl);
        $qrCode = 'data:image/png;base64,'.base64_encode($qrCode);
        return $qrCode ? $qrCode : '';
    }

    //生成恒信二维码
    public static  function  hengQrCode($url)
    {
        //获取邀请链接
        $inviteUrl = InviteConstant::INVITE_URL;

        //生成二维码
        $qrCode = QrCode::format('png')->size('200')->merge('/public/qrcodes/qrcode.png',.15)->generate($url);
        $qrCode = 'data:image/png;base64,'.base64_encode($qrCode);
        return $qrCode ? $qrCode : '';
    }
}